package com.fullmail.adapter;

import java.util.List;

import com.fullmail.R;
import com.fullmail.adapter.ContactListAdapter.ViewHolder;
import com.fullmail.bean.CardBean;
import com.squareup.picasso.Picasso;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CardListAdapter extends BaseAdapter{
	private List<CardBean> list;
	private Context mContext;
	private LayoutInflater inflater;
	public CardListAdapter(Context mContext, List<CardBean> list) {
	
		this.mContext = mContext;
		this.list = list;

	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflater.inflate(R.layout.item_card_view, null);
			holder = new ViewHolder();
			holder.ivHead=(ImageView)convertView.findViewById(R.id.iv_card_head);
			holder.tvName=(TextView)convertView.findViewById(R.id.tv_card_name);
			holder.address=(TextView)convertView.findViewById(R.id.tv_card_address);
			holder.desc=(TextView)convertView.findViewById(R.id.tv_describe);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.tvName.setText(list.get(position).getName());
		holder.address.setText(list.get(position).getAddress());
		holder.desc.setText(list.get(position).getDesc());
		Picasso.with(mContext).load(R.drawable.icon_head).into(holder.ivHead);
		return convertView;
	}
	
	class ViewHolder{
		TextView tvName;
		TextView address;
		TextView desc;
		ImageView ivHead;
	}
	
}
